// components/custom-tabbar/index.js
Component({
  properties: {
    selected: {
      type: Number,
      value: 0
    }
  },

  data: {
    list: [
      {
        pagePath: 'pages/index/index',
        iconPath: 'home_none.png',
        selectedIconPath: 'home_block.png',
        text: '首页'
      },
      {
        pagePath: 'pages/tales/tales',
        iconPath: 'order_none.png',
        selectedIconPath: 'order_block.png',
        text: '预定'
      },
      {
        pagePath: 'pages/profile/profile',
        iconPath: 'main_none.png',
        selectedIconPath: 'main_block.png',
        text: '我的'
      }
    ]
  },

  methods: {
    switchTab(e) {
      console.log(e)
      const { path, index } = e.currentTarget.dataset;
      
      // 触发父组件事件
      // this.triggerEvent('tabchange', {
      //   index: index,
      //   path: path
      // });
      console.log(getCurrentPages()[getCurrentPages().length - 1])
      // 跳转页面
      if (path !== getCurrentPages()[getCurrentPages().length - 1].route) {
        wx.reLaunch({
          url: `/${path}`
        });
      }
    }
  }
});